home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / RCSC.ZIP / BIN / HEADER.AWK < prev    next >
Text File  |  1997-01-12  |  2KB  |  96 lines

  1. #********************************************************
  2. #This is part of the Retargetable Concurrent Small C
  3. #distribution (8051 version)
  4. #Copyright 1997 Andy W. K. Yuen
  5. #********************************************************
  6. #awk program to output symbol definitions for specifying
  7. #placement of constants in code and xdata segments
  8. #this program is intended to be invoked with the command
  9. #line option:
  10. #    -v file=input_file_name
  11. #
  12. BEGIN { FS = "=" 
  13.     #read in the config file
  14.     while (getline line < file > 0) {
  15.         if (split(line, param, "=") == 2) {
  16.             if (param[1] == "CLITBEG") cstart = param[2]
  17.             else if (param[1] == "DVARBEG") dstart = param[2]
  18.         }
  19.     }
  20. }
  21. {
  22. if (NF == 2) {
  23.     split($1, name, "_")
  24.     #record previous module name
  25.     if (thismod != name[1]) {
  26.         lastmod = thismod
  27.         thismod = name[1]
  28.         }
  29.  
  30.     #handle literals
  31.     if (name[2] == "litsize") {
  32.         if (litflag) {
  33.             count++
  34.             text[count] = sprintf("%s_lit_at=%s_lit_at+%s_litsize",
  35.                 name[1], lastmod, lastmod)
  36.             count++
  37.             text[count] = sprintf("%s_var_at=%s_var_at+%s_litsize",
  38.                 name[1], lastmod, lastmod)
  39.             total += $2
  40.             }
  41.         else {
  42.             count++
  43.             text[count] = sprintf("%s_lit_at=%s", name[1], cstart)
  44.             count++
  45.             text[count] = sprintf("%s_var_at=%s", name[1], dstart)
  46.             total += $2
  47.             }
  48.         litflag = 1
  49.     }
  50.  
  51.     else if (name[2] == "tasksize") {
  52.         if (taskflag) {
  53.             count++
  54.             text[count] = sprintf("%s_task_at=%s_task_at+%s_tasksize", 
  55.                 name[1], lastmod, lastmod)
  56.             task_size += $2
  57.             }
  58.         else {
  59.             count++
  60.             text[count] = sprintf("%s_task_at=task_start", 
  61.                 name[1])
  62.             task_size += $2
  63.             }
  64.         taskflag = 1
  65.     }
  66.     else if (name[2] == "monsize") {
  67.         if (monflag) {
  68.             count++
  69.             text[count] = sprintf("%s_mon_at=%s_mon_at+%s_monsize", 
  70.                 name[1], lastmod, lastmod)
  71.             mon_size += $2
  72.             }
  73.         else {
  74.             count++
  75.             text[count] = sprintf("%s_mon_at=mon_start", 
  76.                 name[1])
  77.             mon_size += $2
  78.             }
  79.         monflag = 1
  80.     }
  81.     print $0
  82. }
  83. }
  84.  
  85. END { 
  86.     printf "cvar_size=%d\n",total
  87.     printf "mon_size=%d\n", mon_size
  88.     printf "task_size=%d\n", task_size
  89.     print "mon_start=CLITBEG+cvar_size"
  90.     print "task_start=mon_start+mon_size"
  91.     if (count != 0) {
  92.         for (i = 1; i <= count; i++ ) print text[i] 
  93.         }
  94. }
  95.  
  96.